home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’97
/
Whack-A-Bill
/
source code
/
health.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-24
|
7KB
|
381 lines
#include <qdoffscreen.h>
#include "health.h"
void SetBlood (void);
extern WindowPtr gMainWindow;
extern WindowPtr gWindowTwo;
extern GWorldPtr myOffGWorld;
extern Boolean gDone;
int PlayerOneOldScore, PlayerTwoOldScore;
int PlayerOneHealth=10;
int PlayerTwoHealth=10;
int PlayerOneScoreHealth;
int PlayerTwoScoreHealth;
extern Boolean gatesBlood;
extern Boolean aronBlood;
Boolean gatesNextTime;
Boolean aronNextTime;
void UpdateHealth(void)
{
Rect drawingRect;
RGBColor foreColor, backColor;
PicHandle redSquare, graySquare;
redSquare=GetPicture(801);
graySquare=GetPicture(800);
SetPort(gMainWindow);
foreColor.red=65535;
foreColor.green=0;
foreColor.blue=0;
backColor.red=65535;
backColor.green=65535;
backColor.blue=65535;
RGBForeColor(&foreColor);
RGBBackColor(&backColor);
if(PlayerOneHealth > 0)
{
SetRect(&drawingRect,7,419,25,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,7,419,25,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 1)
{
SetRect(&drawingRect,25,419,43,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,25,419,43,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 2)
{
SetRect(&drawingRect,43,419,61,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,43,419,61,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 3)
{
SetRect(&drawingRect,61,419,79,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,61,419,79,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 4)
{
SetRect(&drawingRect,79,419,97,457);
DrawPicture(redSquare,&drawingRect);
gatesNextTime=true;
}
else
{
SetRect(&drawingRect,79,419,97,457);
DrawPicture(graySquare,&drawingRect);
if(gatesNextTime)
{
gatesBlood=true;
SetBlood();
gatesNextTime=false;
}
}
if(PlayerOneHealth > 5)
{
SetRect(&drawingRect,97,419,115,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,97,419,115,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 6)
{
SetRect(&drawingRect,115,419,133,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,115,419,133,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 7)
{
SetRect(&drawingRect,133,419,151,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,133,419,151,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 8)
{
SetRect(&drawingRect,151,419,169,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,151,419,169,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerOneHealth > 9)
{
SetRect(&drawingRect,169,419,187,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,169,419,187,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 9)
{
SetRect(&drawingRect,213,419,231,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,213,419,231,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 8)
{
SetRect(&drawingRect,231,419,249,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,231,419,249,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 7)
{
SetRect(&drawingRect,249,419,267,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,249,419,267,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 6)
{
SetRect(&drawingRect,267,419,285,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,267,419,285,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 5)
{
SetRect(&drawingRect,285,419,303,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,285,419,303,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 4)
{
SetRect(&drawingRect,303,419,321,457);
DrawPicture(redSquare,&drawingRect);
aronNextTime=true;
}
else
{
SetRect(&drawingRect,302,419,321,457);
DrawPicture(graySquare,&drawingRect);
if(aronNextTime)
{
aronBlood=true;
SetBlood();
aronNextTime=false;
}
}
if(PlayerTwoHealth > 3)
{
SetRect(&drawingRect,321,419,339,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,321,419,339,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 2)
{
SetRect(&drawingRect,339,419,357,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,339,419,357,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 1)
{
SetRect(&drawingRect,357,419,375,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,357,419,375,457);
DrawPicture(graySquare,&drawingRect);
}
if(PlayerTwoHealth > 0)
{
SetRect(&drawingRect,375,419,393,457);
DrawPicture(redSquare,&drawingRect);
}
else
{
SetRect(&drawingRect,375,419,393,457);
DrawPicture(graySquare,&drawingRect);
}
}
void SetHealth(int PlayerOneScoreHealth, int PlayerTwoScoreHealth)
{
if(PlayerTwoScoreHealth>(PlayerTwoOldScore+10))
{
PlayerOneHealth--;
PlayerTwoOldScore=PlayerTwoScoreHealth;
UpdateHealth();
if (PlayerOneHealth==0)
PlayerTwoWins();
if (PlayerOneHealth==5)
gatesBlood=true;
}
if(PlayerOneScoreHealth>(PlayerOneOldScore+10))
{
PlayerTwoHealth--;
PlayerOneOldScore=PlayerOneScoreHealth;
UpdateHealth();
if (PlayerTwoHealth==0)
PlayerOneWins();
if (PlayerTwoHealth==5)
aronBlood=true;
}
}
void PlayerOneWins(void)
{
PicHandle finalPicture;
KeyMap keyMap;
Rect finalRect;
Boolean nextRound=false;
SetRect(&finalRect,0,0,320,210);
finalPicture=GetPicture(3000);
PlayerOneHealth=10;
PlayerTwoHealth=10;
UpdateHealth();
SetPort(gWindowTwo);
DrawPicture(finalPicture,&finalRect);
while(!((keyMap[1] >> 9) & 0x01))
GetKeys(keyMap);
FlushEvents (everyEvent, 0);
aronBlood=false;
gatesBlood=false;
LoadImages();
}
void PlayerTwoWins(void)
{
PicHandle finalPicture;
KeyMap keyMap;
Rect finalRect;
Boolean nextRound=false;
SetRect(&finalRect,0,0,320,210);
finalPicture=GetPicture(3001);
PlayerOneHealth=10;
PlayerTwoHealth=10;
UpdateHealth();
SetPort(gWindowTwo);
DrawPicture(finalPicture,&finalRect);
while(!((keyMap[1] >> 9) & 0x01))
GetKeys(keyMap);
FlushEvents (everyEvent, 0);
aronBlood=false;
gatesBlood=false;
LoadImages();
}
void SetBlood (void)
{
PicHandle playerOnePict;
PicHandle playerTwoPict;
Rect ImageOneRect;
Rect ImageTwoRect;
SetGWorld(myOffGWorld,nil);
SetRect(&ImageOneRect,0,0,640,210);
SetRect(&ImageTwoRect,0,210,640,420);
if(aronBlood)
playerOnePict=GetPicture(668);
else
playerOnePict=GetPicture(667);
if(gatesBlood)
playerTwoPict=GetPicture(14);
else
playerTwoPict=GetPicture(13);
DrawPicture(playerOnePict,&ImageOneRect);
DrawPicture(playerTwoPict,&ImageTwoRect);
}